



// This code is a generated code by a tool
// designed and coded by Shohdi Mohamed Elsheemy ( shohdi@gmail.com )            

using System;
using System.Collections.Generic;
using System.Web;
using System.Data.Common;
using Shohdi.DataHandler;
using System.Data;




namespace DatabaseComponent
{
    
    public partial class PersonsDB
    {
         string _Connection = "";


        public string Connection
        {
            get { return _Connection; }
            set { _Connection = value; }
        }


       
         string _Provider = "System.Data.SqlClient";

        
        public string Provider
        {
            get { return _Provider; }
            set { _Provider = value; }
        }



        public PersonsDB()
        {
        }

        public PersonsDB(string __Connection,params string [] __Provider)
        {

            if (__Provider.Length > 0)
                _Provider = __Provider[0];

            _Connection = __Connection;
            
        }




        public List<Persons> Select(ClassDataHandler con, string strTop, string strWhere, params DbParameter[] whereParams)
        {
            if (whereParams == null)
                whereParams = new DbParameter[0];

            List<Persons> lstRet = new List<Persons>();

            string strQuery = " select " + strTop  + " * from dbo.[Persons]  " ;

            strWhere = GlobalThings.getWhereWithoutDeleted(strWhere);

            if (strWhere != "")
            {
                strQuery = strQuery + "  " + strWhere;
            }

            DbDataReader dr = con.SelectDataReader(strQuery, CommandType.Text, whereParams);


            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Persons obj = new Persons();
 if (dr["GenID"] != DBNull.Value)
                    {
                        obj.GenID = (System.Int64)dr["GenID"];
                    }
                    else
                    {
                        obj.GenID = -1;
                    } 
 if (dr["Name_AR"] != DBNull.Value)
                    {
                        obj.Name_AR = (System.String)dr["Name_AR"];
                    }
                    else
                    {
                        obj.Name_AR = "";
                    } 
 if (dr["Name_EN"] != DBNull.Value)
                    {
                        obj.Name_EN = (System.String)dr["Name_EN"];
                    }
                    else
                    {
                        obj.Name_EN = "";
                    } 
 if (dr["MiddleName_AR"] != DBNull.Value)
                    {
                        obj.MiddleName_AR = (System.String)dr["MiddleName_AR"];
                    }
                    else
                    {
                        obj.MiddleName_AR = "";
                    } 
 if (dr["MiddleName_EN"] != DBNull.Value)
                    {
                        obj.MiddleName_EN = (System.String)dr["MiddleName_EN"];
                    }
                    else
                    {
                        obj.MiddleName_EN = "";
                    } 
 if (dr["FamilyName_AR"] != DBNull.Value)
                    {
                        obj.FamilyName_AR = (System.String)dr["FamilyName_AR"];
                    }
                    else
                    {
                        obj.FamilyName_AR = "";
                    } 
 if (dr["FamilyName_EN"] != DBNull.Value)
                    {
                        obj.FamilyName_EN = (System.String)dr["FamilyName_EN"];
                    }
                    else
                    {
                        obj.FamilyName_EN = "";
                    } 
 if (dr["Gender"] != DBNull.Value)
                    {
                        obj.Gender = (System.Boolean)dr["Gender"];
                    }
                    else
                    {
                        obj.Gender = false;
                    } 
 if (dr["Badge"] != DBNull.Value)
                    {
                        obj.Badge = (System.String)dr["Badge"];
                    }
                    else
                    {
                        obj.Badge = "";
                    } 
 if (dr["ID"] != DBNull.Value)
                    {
                        obj.ID = (System.String)dr["ID"];
                    }
                    else
                    {
                        obj.ID = "";
                    } 
 if (dr["BirthDate"] != DBNull.Value)
                    {
                        obj.BirthDate = (System.DateTime?)dr["BirthDate"];
                    }
                    else
                    {
                        obj.BirthDate = null;
                    } 
 if (dr["RelationID"] != DBNull.Value)
                    {
                        obj.RelationID = (System.Int64?)dr["RelationID"];
                    }
                    else
                    {
                        obj.RelationID = null;
                    } 
 if (dr["NationalityID"] != DBNull.Value)
                    {
                        obj.NationalityID = (System.Int64?)dr["NationalityID"];
                    }
                    else
                    {
                        obj.NationalityID = null;
                    } 
 if (dr["OperationAreaID"] != DBNull.Value)
                    {
                        obj.OperationAreaID = (System.Int64?)dr["OperationAreaID"];
                    }
                    else
                    {
                        obj.OperationAreaID = null;
                    } 
 if (dr["PersonTypeID"] != DBNull.Value)
                    {
                        obj.PersonTypeID = (System.Int64?)dr["PersonTypeID"];
                    }
                    else
                    {
                        obj.PersonTypeID = null;
                    } 
 if (dr["ChargeAccount"] != DBNull.Value)
                    {
                        obj.ChargeAccount = (System.String)dr["ChargeAccount"];
                    }
                    else
                    {
                        obj.ChargeAccount = "";
                    } 
 if (dr["OrgChartID"] != DBNull.Value)
                    {
                        obj.OrgChartID = (System.Int64?)dr["OrgChartID"];
                    }
                    else
                    {
                        obj.OrgChartID = null;
                    } 
 if (dr["Email"] != DBNull.Value)
                    {
                        obj.Email = (System.String)dr["Email"];
                    }
                    else
                    {
                        obj.Email = "";
                    } 
 if (dr["Password"] != DBNull.Value)
                    {
                        obj.Password = (System.String)dr["Password"];
                    }
                    else
                    {
                        obj.Password = "";
                    } 
 if (dr["UserTypeID"] != DBNull.Value)
                    {
                        obj.UserTypeID = (System.Int64)dr["UserTypeID"];
                    }
                    else
                    {
                        obj.UserTypeID = -1;
                    } 
 if (dr["Mobile1"] != DBNull.Value)
                    {
                        obj.Mobile1 = (System.String)dr["Mobile1"];
                    }
                    else
                    {
                        obj.Mobile1 = "";
                    } 
 if (dr["Mobile2"] != DBNull.Value)
                    {
                        obj.Mobile2 = (System.String)dr["Mobile2"];
                    }
                    else
                    {
                        obj.Mobile2 = "";
                    } 
 if (dr["Phone1"] != DBNull.Value)
                    {
                        obj.Phone1 = (System.String)dr["Phone1"];
                    }
                    else
                    {
                        obj.Phone1 = "";
                    } 
 if (dr["InnerPhone1"] != DBNull.Value)
                    {
                        obj.InnerPhone1 = (System.String)dr["InnerPhone1"];
                    }
                    else
                    {
                        obj.InnerPhone1 = "";
                    } 
 if (dr["Phone2"] != DBNull.Value)
                    {
                        obj.Phone2 = (System.String)dr["Phone2"];
                    }
                    else
                    {
                        obj.Phone2 = "";
                    } 
 if (dr["InnerPhone2"] != DBNull.Value)
                    {
                        obj.InnerPhone2 = (System.String)dr["InnerPhone2"];
                    }
                    else
                    {
                        obj.InnerPhone2 = "";
                    } 
 if (dr["Language"] != DBNull.Value)
                    {
                        obj.Language = (System.Int64?)dr["Language"];
                    }
                    else
                    {
                        obj.Language = null;
                    } 
 if (dr["StatusID"] != DBNull.Value)
                    {
                        obj.StatusID = (System.Int64)dr["StatusID"];
                    }
                    else
                    {
                        obj.StatusID = -1;
                    } 
 if (dr["EmploymentStatus"] != DBNull.Value)
                    {
                        obj.EmploymentStatus = (System.Int64?)dr["EmploymentStatus"];
                    }
                    else
                    {
                        obj.EmploymentStatus = null;
                    } 
 if (dr["EducationLevel"] != DBNull.Value)
                    {
                        obj.EducationLevel = (System.Int64)dr["EducationLevel"];
                    }
                    else
                    {
                        obj.EducationLevel = -1;
                    } 
 if (dr["PositionEmail"] != DBNull.Value)
                    {
                        obj.PositionEmail = (System.String)dr["PositionEmail"];
                    }
                    else
                    {
                        obj.PositionEmail = "";
                    } 
 if (dr["OfficePhone"] != DBNull.Value)
                    {
                        obj.OfficePhone = (System.String)dr["OfficePhone"];
                    }
                    else
                    {
                        obj.OfficePhone = "";
                    } 
 if (dr["OfficeInnerPhone"] != DBNull.Value)
                    {
                        obj.OfficeInnerPhone = (System.String)dr["OfficeInnerPhone"];
                    }
                    else
                    {
                        obj.OfficeInnerPhone = "";
                    } 



                    lstRet.Add(obj);
                   

                }
            }

            dr.Close();


            return lstRet;
        }


        public List<Persons> Select(string strTop, string strWhere, params DbParameter[] whereParams)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<Persons> lstRet = Select(con, strTop, strWhere, whereParams);

            con.CloseConnection();

            return lstRet;
        }

        



        public void Insert(ClassDataHandler con , Persons obj)
        {
            
            

                    DbParameter prmName_AR = con.createParameter();
                    prmName_AR.ParameterName = "@Name_AR";
                    prmName_AR.DbType =DbType.String;
                    if (obj.Name_AR == null)
                    {
                        prmName_AR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmName_AR.Value = obj.Name_AR;
                    }
                

                    


                    DbParameter prmName_EN = con.createParameter();
                    prmName_EN.ParameterName = "@Name_EN";
                    prmName_EN.DbType =DbType.String;
                    if (obj.Name_EN == null)
                    {
                        prmName_EN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmName_EN.Value = obj.Name_EN;
                    }
                

                    


                    DbParameter prmMiddleName_AR = con.createParameter();
                    prmMiddleName_AR.ParameterName = "@MiddleName_AR";
                    prmMiddleName_AR.DbType =DbType.String;
                    if (obj.MiddleName_AR == null)
                    {
                        prmMiddleName_AR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmMiddleName_AR.Value = obj.MiddleName_AR;
                    }
                

                    


                    DbParameter prmMiddleName_EN = con.createParameter();
                    prmMiddleName_EN.ParameterName = "@MiddleName_EN";
                    prmMiddleName_EN.DbType =DbType.String;
                    if (obj.MiddleName_EN == null)
                    {
                        prmMiddleName_EN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmMiddleName_EN.Value = obj.MiddleName_EN;
                    }
                

                    


                    DbParameter prmFamilyName_AR = con.createParameter();
                    prmFamilyName_AR.ParameterName = "@FamilyName_AR";
                    prmFamilyName_AR.DbType =DbType.String;
                    if (obj.FamilyName_AR == null)
                    {
                        prmFamilyName_AR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmFamilyName_AR.Value = obj.FamilyName_AR;
                    }
                

                    


                    DbParameter prmFamilyName_EN = con.createParameter();
                    prmFamilyName_EN.ParameterName = "@FamilyName_EN";
                    prmFamilyName_EN.DbType =DbType.String;
                    if (obj.FamilyName_EN == null)
                    {
                        prmFamilyName_EN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmFamilyName_EN.Value = obj.FamilyName_EN;
                    }
                

                    


                    DbParameter prmGender = con.createParameter();
                    prmGender.ParameterName = "@Gender";
                    prmGender.DbType =DbType.Boolean;
                    if (obj.Gender == null)
                    {
                        prmGender.Value = DBNull.Value;
                    }
                    else
                    {
                        prmGender.Value = obj.Gender;
                    }
                

                    


                    DbParameter prmBadge = con.createParameter();
                    prmBadge.ParameterName = "@Badge";
                    prmBadge.DbType =DbType.String;
                    if (obj.Badge == null)
                    {
                        prmBadge.Value = DBNull.Value;
                    }
                    else
                    {
                        prmBadge.Value = obj.Badge;
                    }
                

                    


                    DbParameter prmID = con.createParameter();
                    prmID.ParameterName = "@ID";
                    prmID.DbType =DbType.String;
                    if (obj.ID == null)
                    {
                        prmID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmID.Value = obj.ID;
                    }
                

                    


                    DbParameter prmBirthDate = con.createParameter();
                    prmBirthDate.ParameterName = "@BirthDate";
                    prmBirthDate.DbType =DbType.DateTime;
                    if (obj.BirthDate == null)
                    {
                        prmBirthDate.Value = DBNull.Value;
                    }
                    else
                    {
                        prmBirthDate.Value = obj.BirthDate;
                    }
                

                    


                    DbParameter prmRelationID = con.createParameter();
                    prmRelationID.ParameterName = "@RelationID";
                    prmRelationID.DbType =DbType.Int64;
                    if (obj.RelationID == null)
                    {
                        prmRelationID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmRelationID.Value = obj.RelationID;
                    }
                

                    


                    DbParameter prmNationalityID = con.createParameter();
                    prmNationalityID.ParameterName = "@NationalityID";
                    prmNationalityID.DbType =DbType.Int64;
                    if (obj.NationalityID == null)
                    {
                        prmNationalityID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmNationalityID.Value = obj.NationalityID;
                    }
                

                    


                    DbParameter prmOperationAreaID = con.createParameter();
                    prmOperationAreaID.ParameterName = "@OperationAreaID";
                    prmOperationAreaID.DbType =DbType.Int64;
                    if (obj.OperationAreaID == null)
                    {
                        prmOperationAreaID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmOperationAreaID.Value = obj.OperationAreaID;
                    }
                

                    


                    DbParameter prmPersonTypeID = con.createParameter();
                    prmPersonTypeID.ParameterName = "@PersonTypeID";
                    prmPersonTypeID.DbType =DbType.Int64;
                    if (obj.PersonTypeID == null)
                    {
                        prmPersonTypeID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPersonTypeID.Value = obj.PersonTypeID;
                    }
                

                    


                    DbParameter prmChargeAccount = con.createParameter();
                    prmChargeAccount.ParameterName = "@ChargeAccount";
                    prmChargeAccount.DbType =DbType.String;
                    if (obj.ChargeAccount == null)
                    {
                        prmChargeAccount.Value = DBNull.Value;
                    }
                    else
                    {
                        prmChargeAccount.Value = obj.ChargeAccount;
                    }
                

                    


                    DbParameter prmOrgChartID = con.createParameter();
                    prmOrgChartID.ParameterName = "@OrgChartID";
                    prmOrgChartID.DbType =DbType.Int64;
                    if (obj.OrgChartID == null)
                    {
                        prmOrgChartID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmOrgChartID.Value = obj.OrgChartID;
                    }
                

                    


                    DbParameter prmEmail = con.createParameter();
                    prmEmail.ParameterName = "@Email";
                    prmEmail.DbType =DbType.String;
                    if (obj.Email == null)
                    {
                        prmEmail.Value = DBNull.Value;
                    }
                    else
                    {
                        prmEmail.Value = obj.Email;
                    }
                

                    


                    DbParameter prmPassword = con.createParameter();
                    prmPassword.ParameterName = "@Password";
                    prmPassword.DbType =DbType.String;
                    if (obj.Password == null)
                    {
                        prmPassword.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPassword.Value = obj.Password;
                    }
                

                    


                    DbParameter prmUserTypeID = con.createParameter();
                    prmUserTypeID.ParameterName = "@UserTypeID";
                    prmUserTypeID.DbType =DbType.Int64;
                    if (obj.UserTypeID == null)
                    {
                        prmUserTypeID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmUserTypeID.Value = obj.UserTypeID;
                    }
                

                    


                    DbParameter prmMobile1 = con.createParameter();
                    prmMobile1.ParameterName = "@Mobile1";
                    prmMobile1.DbType =DbType.String;
                    if (obj.Mobile1 == null)
                    {
                        prmMobile1.Value = DBNull.Value;
                    }
                    else
                    {
                        prmMobile1.Value = obj.Mobile1;
                    }
                

                    


                    DbParameter prmMobile2 = con.createParameter();
                    prmMobile2.ParameterName = "@Mobile2";
                    prmMobile2.DbType =DbType.String;
                    if (obj.Mobile2 == null)
                    {
                        prmMobile2.Value = DBNull.Value;
                    }
                    else
                    {
                        prmMobile2.Value = obj.Mobile2;
                    }
                

                    


                    DbParameter prmPhone1 = con.createParameter();
                    prmPhone1.ParameterName = "@Phone1";
                    prmPhone1.DbType =DbType.String;
                    if (obj.Phone1 == null)
                    {
                        prmPhone1.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPhone1.Value = obj.Phone1;
                    }
                

                    


                    DbParameter prmInnerPhone1 = con.createParameter();
                    prmInnerPhone1.ParameterName = "@InnerPhone1";
                    prmInnerPhone1.DbType =DbType.String;
                    if (obj.InnerPhone1 == null)
                    {
                        prmInnerPhone1.Value = DBNull.Value;
                    }
                    else
                    {
                        prmInnerPhone1.Value = obj.InnerPhone1;
                    }
                

                    


                    DbParameter prmPhone2 = con.createParameter();
                    prmPhone2.ParameterName = "@Phone2";
                    prmPhone2.DbType =DbType.String;
                    if (obj.Phone2 == null)
                    {
                        prmPhone2.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPhone2.Value = obj.Phone2;
                    }
                

                    


                    DbParameter prmInnerPhone2 = con.createParameter();
                    prmInnerPhone2.ParameterName = "@InnerPhone2";
                    prmInnerPhone2.DbType =DbType.String;
                    if (obj.InnerPhone2 == null)
                    {
                        prmInnerPhone2.Value = DBNull.Value;
                    }
                    else
                    {
                        prmInnerPhone2.Value = obj.InnerPhone2;
                    }
                

                    


                    DbParameter prmLanguage = con.createParameter();
                    prmLanguage.ParameterName = "@Language";
                    prmLanguage.DbType =DbType.Int64;
                    if (obj.Language == null)
                    {
                        prmLanguage.Value = DBNull.Value;
                    }
                    else
                    {
                        prmLanguage.Value = obj.Language;
                    }
                

                    


                    DbParameter prmStatusID = con.createParameter();
                    prmStatusID.ParameterName = "@StatusID";
                    prmStatusID.DbType =DbType.Int64;
                    if (obj.StatusID == null)
                    {
                        prmStatusID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmStatusID.Value = obj.StatusID;
                    }
                

                    


                    DbParameter prmEmploymentStatus = con.createParameter();
                    prmEmploymentStatus.ParameterName = "@EmploymentStatus";
                    prmEmploymentStatus.DbType =DbType.Int64;
                    if (obj.EmploymentStatus == null)
                    {
                        prmEmploymentStatus.Value = DBNull.Value;
                    }
                    else
                    {
                        prmEmploymentStatus.Value = obj.EmploymentStatus;
                    }
                

                    


                    DbParameter prmEducationLevel = con.createParameter();
                    prmEducationLevel.ParameterName = "@EducationLevel";
                    prmEducationLevel.DbType =DbType.Int64;
                    if (obj.EducationLevel == null)
                    {
                        prmEducationLevel.Value = DBNull.Value;
                    }
                    else
                    {
                        prmEducationLevel.Value = obj.EducationLevel;
                    }
                

                    


                    DbParameter prmPositionEmail = con.createParameter();
                    prmPositionEmail.ParameterName = "@PositionEmail";
                    prmPositionEmail.DbType =DbType.String;
                    if (obj.PositionEmail == null)
                    {
                        prmPositionEmail.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPositionEmail.Value = obj.PositionEmail;
                    }
                

                    


                    DbParameter prmOfficePhone = con.createParameter();
                    prmOfficePhone.ParameterName = "@OfficePhone";
                    prmOfficePhone.DbType =DbType.String;
                    if (obj.OfficePhone == null)
                    {
                        prmOfficePhone.Value = DBNull.Value;
                    }
                    else
                    {
                        prmOfficePhone.Value = obj.OfficePhone;
                    }
                

                    


                    DbParameter prmOfficeInnerPhone = con.createParameter();
                    prmOfficeInnerPhone.ParameterName = "@OfficeInnerPhone";
                    prmOfficeInnerPhone.DbType =DbType.String;
                    if (obj.OfficeInnerPhone == null)
                    {
                        prmOfficeInnerPhone.Value = DBNull.Value;
                    }
                    else
                    {
                        prmOfficeInnerPhone.Value = obj.OfficeInnerPhone;
                    }
                

                    


           



            string strQuery = " insert into dbo.[Persons] ([Name_AR],[Name_EN],[MiddleName_AR],[MiddleName_EN],[FamilyName_AR],[FamilyName_EN],[Gender],[Badge],[ID],[BirthDate],[RelationID],[NationalityID],[OperationAreaID],[PersonTypeID],[ChargeAccount],[OrgChartID],[Email],[Password],[UserTypeID],[Mobile1],[Mobile2],[Phone1],[InnerPhone1],[Phone2],[InnerPhone2],[Language],[StatusID],[EmploymentStatus],[EducationLevel],[PositionEmail],[OfficePhone],[OfficeInnerPhone]) VALUES (@Name_AR,@Name_EN,@MiddleName_AR,@MiddleName_EN,@FamilyName_AR,@FamilyName_EN,@Gender,@Badge,@ID,@BirthDate,@RelationID,@NationalityID,@OperationAreaID,@PersonTypeID,@ChargeAccount,@OrgChartID,@Email,@Password,@UserTypeID,@Mobile1,@Mobile2,@Phone1,@InnerPhone1,@Phone2,@InnerPhone2,@Language,@StatusID,@EmploymentStatus,@EducationLevel,@PositionEmail,@OfficePhone,@OfficeInnerPhone) ; select SCOPE_IDENTITY() ";
 object scope = con.ExecuteScalar(strQuery, CommandType.Text, prmName_AR,prmName_EN,prmMiddleName_AR,prmMiddleName_EN,prmFamilyName_AR,prmFamilyName_EN,prmGender,prmBadge,prmID,prmBirthDate,prmRelationID,prmNationalityID,prmOperationAreaID,prmPersonTypeID,prmChargeAccount,prmOrgChartID,prmEmail,prmPassword,prmUserTypeID,prmMobile1,prmMobile2,prmPhone1,prmInnerPhone1,prmPhone2,prmInnerPhone2,prmLanguage,prmStatusID,prmEmploymentStatus,prmEducationLevel,prmPositionEmail,prmOfficePhone,prmOfficeInnerPhone);


                    try
                    {
                        obj.GenID = System.Int64.Parse(scope.ToString());
                    }
                    catch
                    {
                        obj.GenID = -1;
                    }


                    


           

        }



        public void Insert(Persons obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Insert(con,obj);


            con.CloseConnection();
        }




        public void Update(ClassDataHandler con, Persons obj)
        {
            
            

                    DbParameter prmGenID = con.createParameter();
                    prmGenID.ParameterName = "@GenID";
                    prmGenID.DbType =DbType.Int64;
                    if (obj.GenID == null)
                    {
                        prmGenID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmGenID.Value = obj.GenID;
                    }
                

                    


                    DbParameter prmName_AR = con.createParameter();
                    prmName_AR.ParameterName = "@Name_AR";
                    prmName_AR.DbType =DbType.String;
                    if (obj.Name_AR == null)
                    {
                        prmName_AR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmName_AR.Value = obj.Name_AR;
                    }
                

                    


                    DbParameter prmName_EN = con.createParameter();
                    prmName_EN.ParameterName = "@Name_EN";
                    prmName_EN.DbType =DbType.String;
                    if (obj.Name_EN == null)
                    {
                        prmName_EN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmName_EN.Value = obj.Name_EN;
                    }
                

                    


                    DbParameter prmMiddleName_AR = con.createParameter();
                    prmMiddleName_AR.ParameterName = "@MiddleName_AR";
                    prmMiddleName_AR.DbType =DbType.String;
                    if (obj.MiddleName_AR == null)
                    {
                        prmMiddleName_AR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmMiddleName_AR.Value = obj.MiddleName_AR;
                    }
                

                    


                    DbParameter prmMiddleName_EN = con.createParameter();
                    prmMiddleName_EN.ParameterName = "@MiddleName_EN";
                    prmMiddleName_EN.DbType =DbType.String;
                    if (obj.MiddleName_EN == null)
                    {
                        prmMiddleName_EN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmMiddleName_EN.Value = obj.MiddleName_EN;
                    }
                

                    


                    DbParameter prmFamilyName_AR = con.createParameter();
                    prmFamilyName_AR.ParameterName = "@FamilyName_AR";
                    prmFamilyName_AR.DbType =DbType.String;
                    if (obj.FamilyName_AR == null)
                    {
                        prmFamilyName_AR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmFamilyName_AR.Value = obj.FamilyName_AR;
                    }
                

                    


                    DbParameter prmFamilyName_EN = con.createParameter();
                    prmFamilyName_EN.ParameterName = "@FamilyName_EN";
                    prmFamilyName_EN.DbType =DbType.String;
                    if (obj.FamilyName_EN == null)
                    {
                        prmFamilyName_EN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmFamilyName_EN.Value = obj.FamilyName_EN;
                    }
                

                    


                    DbParameter prmGender = con.createParameter();
                    prmGender.ParameterName = "@Gender";
                    prmGender.DbType =DbType.Boolean;
                    if (obj.Gender == null)
                    {
                        prmGender.Value = DBNull.Value;
                    }
                    else
                    {
                        prmGender.Value = obj.Gender;
                    }
                

                    


                    DbParameter prmBadge = con.createParameter();
                    prmBadge.ParameterName = "@Badge";
                    prmBadge.DbType =DbType.String;
                    if (obj.Badge == null)
                    {
                        prmBadge.Value = DBNull.Value;
                    }
                    else
                    {
                        prmBadge.Value = obj.Badge;
                    }
                

                    


                    DbParameter prmID = con.createParameter();
                    prmID.ParameterName = "@ID";
                    prmID.DbType =DbType.String;
                    if (obj.ID == null)
                    {
                        prmID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmID.Value = obj.ID;
                    }
                

                    


                    DbParameter prmBirthDate = con.createParameter();
                    prmBirthDate.ParameterName = "@BirthDate";
                    prmBirthDate.DbType =DbType.DateTime;
                    if (obj.BirthDate == null)
                    {
                        prmBirthDate.Value = DBNull.Value;
                    }
                    else
                    {
                        prmBirthDate.Value = obj.BirthDate;
                    }
                

                    


                    DbParameter prmRelationID = con.createParameter();
                    prmRelationID.ParameterName = "@RelationID";
                    prmRelationID.DbType =DbType.Int64;
                    if (obj.RelationID == null)
                    {
                        prmRelationID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmRelationID.Value = obj.RelationID;
                    }
                

                    


                    DbParameter prmNationalityID = con.createParameter();
                    prmNationalityID.ParameterName = "@NationalityID";
                    prmNationalityID.DbType =DbType.Int64;
                    if (obj.NationalityID == null)
                    {
                        prmNationalityID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmNationalityID.Value = obj.NationalityID;
                    }
                

                    


                    DbParameter prmOperationAreaID = con.createParameter();
                    prmOperationAreaID.ParameterName = "@OperationAreaID";
                    prmOperationAreaID.DbType =DbType.Int64;
                    if (obj.OperationAreaID == null)
                    {
                        prmOperationAreaID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmOperationAreaID.Value = obj.OperationAreaID;
                    }
                

                    


                    DbParameter prmPersonTypeID = con.createParameter();
                    prmPersonTypeID.ParameterName = "@PersonTypeID";
                    prmPersonTypeID.DbType =DbType.Int64;
                    if (obj.PersonTypeID == null)
                    {
                        prmPersonTypeID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPersonTypeID.Value = obj.PersonTypeID;
                    }
                

                    


                    DbParameter prmChargeAccount = con.createParameter();
                    prmChargeAccount.ParameterName = "@ChargeAccount";
                    prmChargeAccount.DbType =DbType.String;
                    if (obj.ChargeAccount == null)
                    {
                        prmChargeAccount.Value = DBNull.Value;
                    }
                    else
                    {
                        prmChargeAccount.Value = obj.ChargeAccount;
                    }
                

                    


                    DbParameter prmOrgChartID = con.createParameter();
                    prmOrgChartID.ParameterName = "@OrgChartID";
                    prmOrgChartID.DbType =DbType.Int64;
                    if (obj.OrgChartID == null)
                    {
                        prmOrgChartID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmOrgChartID.Value = obj.OrgChartID;
                    }
                

                    


                    DbParameter prmEmail = con.createParameter();
                    prmEmail.ParameterName = "@Email";
                    prmEmail.DbType =DbType.String;
                    if (obj.Email == null)
                    {
                        prmEmail.Value = DBNull.Value;
                    }
                    else
                    {
                        prmEmail.Value = obj.Email;
                    }
                

                    


                    DbParameter prmPassword = con.createParameter();
                    prmPassword.ParameterName = "@Password";
                    prmPassword.DbType =DbType.String;
                    if (obj.Password == null)
                    {
                        prmPassword.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPassword.Value = obj.Password;
                    }
                

                    


                    DbParameter prmUserTypeID = con.createParameter();
                    prmUserTypeID.ParameterName = "@UserTypeID";
                    prmUserTypeID.DbType =DbType.Int64;
                    if (obj.UserTypeID == null)
                    {
                        prmUserTypeID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmUserTypeID.Value = obj.UserTypeID;
                    }
                

                    


                    DbParameter prmMobile1 = con.createParameter();
                    prmMobile1.ParameterName = "@Mobile1";
                    prmMobile1.DbType =DbType.String;
                    if (obj.Mobile1 == null)
                    {
                        prmMobile1.Value = DBNull.Value;
                    }
                    else
                    {
                        prmMobile1.Value = obj.Mobile1;
                    }
                

                    


                    DbParameter prmMobile2 = con.createParameter();
                    prmMobile2.ParameterName = "@Mobile2";
                    prmMobile2.DbType =DbType.String;
                    if (obj.Mobile2 == null)
                    {
                        prmMobile2.Value = DBNull.Value;
                    }
                    else
                    {
                        prmMobile2.Value = obj.Mobile2;
                    }
                

                    


                    DbParameter prmPhone1 = con.createParameter();
                    prmPhone1.ParameterName = "@Phone1";
                    prmPhone1.DbType =DbType.String;
                    if (obj.Phone1 == null)
                    {
                        prmPhone1.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPhone1.Value = obj.Phone1;
                    }
                

                    


                    DbParameter prmInnerPhone1 = con.createParameter();
                    prmInnerPhone1.ParameterName = "@InnerPhone1";
                    prmInnerPhone1.DbType =DbType.String;
                    if (obj.InnerPhone1 == null)
                    {
                        prmInnerPhone1.Value = DBNull.Value;
                    }
                    else
                    {
                        prmInnerPhone1.Value = obj.InnerPhone1;
                    }
                

                    


                    DbParameter prmPhone2 = con.createParameter();
                    prmPhone2.ParameterName = "@Phone2";
                    prmPhone2.DbType =DbType.String;
                    if (obj.Phone2 == null)
                    {
                        prmPhone2.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPhone2.Value = obj.Phone2;
                    }
                

                    


                    DbParameter prmInnerPhone2 = con.createParameter();
                    prmInnerPhone2.ParameterName = "@InnerPhone2";
                    prmInnerPhone2.DbType =DbType.String;
                    if (obj.InnerPhone2 == null)
                    {
                        prmInnerPhone2.Value = DBNull.Value;
                    }
                    else
                    {
                        prmInnerPhone2.Value = obj.InnerPhone2;
                    }
                

                    


                    DbParameter prmLanguage = con.createParameter();
                    prmLanguage.ParameterName = "@Language";
                    prmLanguage.DbType =DbType.Int64;
                    if (obj.Language == null)
                    {
                        prmLanguage.Value = DBNull.Value;
                    }
                    else
                    {
                        prmLanguage.Value = obj.Language;
                    }
                

                    


                    DbParameter prmStatusID = con.createParameter();
                    prmStatusID.ParameterName = "@StatusID";
                    prmStatusID.DbType =DbType.Int64;
                    if (obj.StatusID == null)
                    {
                        prmStatusID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmStatusID.Value = obj.StatusID;
                    }
                

                    


                    DbParameter prmEmploymentStatus = con.createParameter();
                    prmEmploymentStatus.ParameterName = "@EmploymentStatus";
                    prmEmploymentStatus.DbType =DbType.Int64;
                    if (obj.EmploymentStatus == null)
                    {
                        prmEmploymentStatus.Value = DBNull.Value;
                    }
                    else
                    {
                        prmEmploymentStatus.Value = obj.EmploymentStatus;
                    }
                

                    


                    DbParameter prmEducationLevel = con.createParameter();
                    prmEducationLevel.ParameterName = "@EducationLevel";
                    prmEducationLevel.DbType =DbType.Int64;
                    if (obj.EducationLevel == null)
                    {
                        prmEducationLevel.Value = DBNull.Value;
                    }
                    else
                    {
                        prmEducationLevel.Value = obj.EducationLevel;
                    }
                

                    


                    DbParameter prmPositionEmail = con.createParameter();
                    prmPositionEmail.ParameterName = "@PositionEmail";
                    prmPositionEmail.DbType =DbType.String;
                    if (obj.PositionEmail == null)
                    {
                        prmPositionEmail.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPositionEmail.Value = obj.PositionEmail;
                    }
                

                    


                    DbParameter prmOfficePhone = con.createParameter();
                    prmOfficePhone.ParameterName = "@OfficePhone";
                    prmOfficePhone.DbType =DbType.String;
                    if (obj.OfficePhone == null)
                    {
                        prmOfficePhone.Value = DBNull.Value;
                    }
                    else
                    {
                        prmOfficePhone.Value = obj.OfficePhone;
                    }
                

                    


                    DbParameter prmOfficeInnerPhone = con.createParameter();
                    prmOfficeInnerPhone.ParameterName = "@OfficeInnerPhone";
                    prmOfficeInnerPhone.DbType =DbType.String;
                    if (obj.OfficeInnerPhone == null)
                    {
                        prmOfficeInnerPhone.Value = DBNull.Value;
                    }
                    else
                    {
                        prmOfficeInnerPhone.Value = obj.OfficeInnerPhone;
                    }
                

                    


           



            string strQuery = " update dbo.[Persons] set [Name_AR]=@Name_AR,[Name_EN]=@Name_EN,[MiddleName_AR]=@MiddleName_AR,[MiddleName_EN]=@MiddleName_EN,[FamilyName_AR]=@FamilyName_AR,[FamilyName_EN]=@FamilyName_EN,[Gender]=@Gender,[Badge]=@Badge,[ID]=@ID,[BirthDate]=@BirthDate,[RelationID]=@RelationID,[NationalityID]=@NationalityID,[OperationAreaID]=@OperationAreaID,[PersonTypeID]=@PersonTypeID,[ChargeAccount]=@ChargeAccount,[OrgChartID]=@OrgChartID,[Email]=@Email,[Password]=@Password,[UserTypeID]=@UserTypeID,[Mobile1]=@Mobile1,[Mobile2]=@Mobile2,[Phone1]=@Phone1,[InnerPhone1]=@InnerPhone1,[Phone2]=@Phone2,[InnerPhone2]=@InnerPhone2,[Language]=@Language,[StatusID]=@StatusID,[EmploymentStatus]=@EmploymentStatus,[EducationLevel]=@EducationLevel,[PositionEmail]=@PositionEmail,[OfficePhone]=@OfficePhone,[OfficeInnerPhone]=@OfficeInnerPhone where  [GenID]=@GenID  ";

            con.ExecuteNonQuery(strQuery, CommandType.Text,prmGenID,prmName_AR,prmName_EN,prmMiddleName_AR,prmMiddleName_EN,prmFamilyName_AR,prmFamilyName_EN,prmGender,prmBadge,prmID,prmBirthDate,prmRelationID,prmNationalityID,prmOperationAreaID,prmPersonTypeID,prmChargeAccount,prmOrgChartID,prmEmail,prmPassword,prmUserTypeID,prmMobile1,prmMobile2,prmPhone1,prmInnerPhone1,prmPhone2,prmInnerPhone2,prmLanguage,prmStatusID,prmEmploymentStatus,prmEducationLevel,prmPositionEmail,prmOfficePhone,prmOfficeInnerPhone);

            

        }


        public void Update(Persons obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Update(con, obj);


            con.CloseConnection();
        }



        public void Delete(ClassDataHandler con, Persons obj)
        {

            

                    DbParameter prmGenID = con.createParameter();
                    prmGenID.ParameterName = "@GenID";
                    prmGenID.DbType =DbType.Int64;
                    if (obj.GenID == null)
                    {
                        prmGenID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmGenID.Value = obj.GenID;
                    }
                

                    


           



           



            string strQuery = " delete from dbo.[Persons]  where  [GenID]=@GenID  "; 
                        con.ExecuteNonQuery(strQuery, CommandType.Text,prmGenID );  

             



        }


        public void Delete( Persons obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            Delete(con, obj);

            con.CloseConnection();
        }





                    public List<Persons> getPersonsByGenID(ClassDataHandler con,System.Int64 GenID)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmGenID = con.createParameter();
                        prmGenID.ParameterName = "@GenID";
                        prmGenID.DbType = DbType.Int64;
                        if (GenID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmGenID.Value = GenID;
                        }


                        lstRet = Select(con, "" , " where [GenID]=@GenID ", prmGenID);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByGenID(System.Int64 GenID)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByGenID(con, GenID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByName_AR(ClassDataHandler con,System.String Name_AR)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmName_AR = con.createParameter();
                        prmName_AR.ParameterName = "@Name_AR";
                        prmName_AR.DbType = DbType.String;
                        if (Name_AR == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmName_AR.Value = Name_AR;
                        }


                        lstRet = Select(con, "" , " where [Name_AR]=@Name_AR ", prmName_AR);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByName_AR(System.String Name_AR)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByName_AR(con, Name_AR);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByName_EN(ClassDataHandler con,System.String Name_EN)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmName_EN = con.createParameter();
                        prmName_EN.ParameterName = "@Name_EN";
                        prmName_EN.DbType = DbType.String;
                        if (Name_EN == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmName_EN.Value = Name_EN;
                        }


                        lstRet = Select(con, "" , " where [Name_EN]=@Name_EN ", prmName_EN);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByName_EN(System.String Name_EN)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByName_EN(con, Name_EN);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByMiddleName_AR(ClassDataHandler con,System.String MiddleName_AR)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmMiddleName_AR = con.createParameter();
                        prmMiddleName_AR.ParameterName = "@MiddleName_AR";
                        prmMiddleName_AR.DbType = DbType.String;
                        if (MiddleName_AR == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmMiddleName_AR.Value = MiddleName_AR;
                        }


                        lstRet = Select(con, "" , " where [MiddleName_AR]=@MiddleName_AR ", prmMiddleName_AR);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByMiddleName_AR(System.String MiddleName_AR)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByMiddleName_AR(con, MiddleName_AR);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByMiddleName_EN(ClassDataHandler con,System.String MiddleName_EN)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmMiddleName_EN = con.createParameter();
                        prmMiddleName_EN.ParameterName = "@MiddleName_EN";
                        prmMiddleName_EN.DbType = DbType.String;
                        if (MiddleName_EN == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmMiddleName_EN.Value = MiddleName_EN;
                        }


                        lstRet = Select(con, "" , " where [MiddleName_EN]=@MiddleName_EN ", prmMiddleName_EN);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByMiddleName_EN(System.String MiddleName_EN)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByMiddleName_EN(con, MiddleName_EN);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByFamilyName_AR(ClassDataHandler con,System.String FamilyName_AR)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmFamilyName_AR = con.createParameter();
                        prmFamilyName_AR.ParameterName = "@FamilyName_AR";
                        prmFamilyName_AR.DbType = DbType.String;
                        if (FamilyName_AR == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmFamilyName_AR.Value = FamilyName_AR;
                        }


                        lstRet = Select(con, "" , " where [FamilyName_AR]=@FamilyName_AR ", prmFamilyName_AR);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByFamilyName_AR(System.String FamilyName_AR)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByFamilyName_AR(con, FamilyName_AR);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByFamilyName_EN(ClassDataHandler con,System.String FamilyName_EN)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmFamilyName_EN = con.createParameter();
                        prmFamilyName_EN.ParameterName = "@FamilyName_EN";
                        prmFamilyName_EN.DbType = DbType.String;
                        if (FamilyName_EN == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmFamilyName_EN.Value = FamilyName_EN;
                        }


                        lstRet = Select(con, "" , " where [FamilyName_EN]=@FamilyName_EN ", prmFamilyName_EN);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByFamilyName_EN(System.String FamilyName_EN)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByFamilyName_EN(con, FamilyName_EN);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByGender(ClassDataHandler con,System.Boolean Gender)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmGender = con.createParameter();
                        prmGender.ParameterName = "@Gender";
                        prmGender.DbType = DbType.Boolean;
                        if (Gender == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmGender.Value = Gender;
                        }


                        lstRet = Select(con, "" , " where [Gender]=@Gender ", prmGender);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByGender(System.Boolean Gender)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByGender(con, Gender);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByBadge(ClassDataHandler con,System.String Badge)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmBadge = con.createParameter();
                        prmBadge.ParameterName = "@Badge";
                        prmBadge.DbType = DbType.String;
                        if (Badge == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmBadge.Value = Badge;
                        }


                        lstRet = Select(con, "" , " where [Badge]=@Badge ", prmBadge);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByBadge(System.String Badge)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByBadge(con, Badge);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByID(ClassDataHandler con,System.String ID)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType = DbType.String;
                        if (ID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmID.Value = ID;
                        }


                        lstRet = Select(con, "" , " where [ID]=@ID ", prmID);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByID(System.String ID)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByID(con, ID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByBirthDate(ClassDataHandler con,System.DateTime? BirthDate)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmBirthDate = con.createParameter();
                        prmBirthDate.ParameterName = "@BirthDate";
                        prmBirthDate.DbType = DbType.DateTime;
                        if (BirthDate == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmBirthDate.Value = BirthDate;
                        }


                        lstRet = Select(con, "" , " where [BirthDate]=@BirthDate ", prmBirthDate);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByBirthDate(System.DateTime? BirthDate)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByBirthDate(con, BirthDate);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByRelationID(ClassDataHandler con,System.Int64? RelationID)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmRelationID = con.createParameter();
                        prmRelationID.ParameterName = "@RelationID";
                        prmRelationID.DbType = DbType.Int64;
                        if (RelationID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmRelationID.Value = RelationID;
                        }


                        lstRet = Select(con, "" , " where [RelationID]=@RelationID ", prmRelationID);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByRelationID(System.Int64? RelationID)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByRelationID(con, RelationID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByNationalityID(ClassDataHandler con,System.Int64? NationalityID)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmNationalityID = con.createParameter();
                        prmNationalityID.ParameterName = "@NationalityID";
                        prmNationalityID.DbType = DbType.Int64;
                        if (NationalityID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmNationalityID.Value = NationalityID;
                        }


                        lstRet = Select(con, "" , " where [NationalityID]=@NationalityID ", prmNationalityID);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByNationalityID(System.Int64? NationalityID)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByNationalityID(con, NationalityID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByOperationAreaID(ClassDataHandler con,System.Int64? OperationAreaID)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmOperationAreaID = con.createParameter();
                        prmOperationAreaID.ParameterName = "@OperationAreaID";
                        prmOperationAreaID.DbType = DbType.Int64;
                        if (OperationAreaID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmOperationAreaID.Value = OperationAreaID;
                        }


                        lstRet = Select(con, "" , " where [OperationAreaID]=@OperationAreaID ", prmOperationAreaID);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByOperationAreaID(System.Int64? OperationAreaID)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByOperationAreaID(con, OperationAreaID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByPersonTypeID(ClassDataHandler con,System.Int64? PersonTypeID)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmPersonTypeID = con.createParameter();
                        prmPersonTypeID.ParameterName = "@PersonTypeID";
                        prmPersonTypeID.DbType = DbType.Int64;
                        if (PersonTypeID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmPersonTypeID.Value = PersonTypeID;
                        }


                        lstRet = Select(con, "" , " where [PersonTypeID]=@PersonTypeID ", prmPersonTypeID);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByPersonTypeID(System.Int64? PersonTypeID)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByPersonTypeID(con, PersonTypeID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByChargeAccount(ClassDataHandler con,System.String ChargeAccount)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmChargeAccount = con.createParameter();
                        prmChargeAccount.ParameterName = "@ChargeAccount";
                        prmChargeAccount.DbType = DbType.String;
                        if (ChargeAccount == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmChargeAccount.Value = ChargeAccount;
                        }


                        lstRet = Select(con, "" , " where [ChargeAccount]=@ChargeAccount ", prmChargeAccount);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByChargeAccount(System.String ChargeAccount)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByChargeAccount(con, ChargeAccount);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByOrgChartID(ClassDataHandler con,System.Int64? OrgChartID)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmOrgChartID = con.createParameter();
                        prmOrgChartID.ParameterName = "@OrgChartID";
                        prmOrgChartID.DbType = DbType.Int64;
                        if (OrgChartID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmOrgChartID.Value = OrgChartID;
                        }


                        lstRet = Select(con, "" , " where [OrgChartID]=@OrgChartID ", prmOrgChartID);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByOrgChartID(System.Int64? OrgChartID)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByOrgChartID(con, OrgChartID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByEmail(ClassDataHandler con,System.String Email)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmEmail = con.createParameter();
                        prmEmail.ParameterName = "@Email";
                        prmEmail.DbType = DbType.String;
                        if (Email == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmEmail.Value = Email;
                        }


                        lstRet = Select(con, "" , " where [Email]=@Email ", prmEmail);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByEmail(System.String Email)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByEmail(con, Email);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByPassword(ClassDataHandler con,System.String Password)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmPassword = con.createParameter();
                        prmPassword.ParameterName = "@Password";
                        prmPassword.DbType = DbType.String;
                        if (Password == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmPassword.Value = Password;
                        }


                        lstRet = Select(con, "" , " where [Password]=@Password ", prmPassword);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByPassword(System.String Password)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByPassword(con, Password);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByUserTypeID(ClassDataHandler con,System.Int64 UserTypeID)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmUserTypeID = con.createParameter();
                        prmUserTypeID.ParameterName = "@UserTypeID";
                        prmUserTypeID.DbType = DbType.Int64;
                        if (UserTypeID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmUserTypeID.Value = UserTypeID;
                        }


                        lstRet = Select(con, "" , " where [UserTypeID]=@UserTypeID ", prmUserTypeID);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByUserTypeID(System.Int64 UserTypeID)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByUserTypeID(con, UserTypeID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByMobile1(ClassDataHandler con,System.String Mobile1)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmMobile1 = con.createParameter();
                        prmMobile1.ParameterName = "@Mobile1";
                        prmMobile1.DbType = DbType.String;
                        if (Mobile1 == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmMobile1.Value = Mobile1;
                        }


                        lstRet = Select(con, "" , " where [Mobile1]=@Mobile1 ", prmMobile1);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByMobile1(System.String Mobile1)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByMobile1(con, Mobile1);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByMobile2(ClassDataHandler con,System.String Mobile2)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmMobile2 = con.createParameter();
                        prmMobile2.ParameterName = "@Mobile2";
                        prmMobile2.DbType = DbType.String;
                        if (Mobile2 == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmMobile2.Value = Mobile2;
                        }


                        lstRet = Select(con, "" , " where [Mobile2]=@Mobile2 ", prmMobile2);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByMobile2(System.String Mobile2)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByMobile2(con, Mobile2);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByPhone1(ClassDataHandler con,System.String Phone1)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmPhone1 = con.createParameter();
                        prmPhone1.ParameterName = "@Phone1";
                        prmPhone1.DbType = DbType.String;
                        if (Phone1 == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmPhone1.Value = Phone1;
                        }


                        lstRet = Select(con, "" , " where [Phone1]=@Phone1 ", prmPhone1);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByPhone1(System.String Phone1)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByPhone1(con, Phone1);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByInnerPhone1(ClassDataHandler con,System.String InnerPhone1)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmInnerPhone1 = con.createParameter();
                        prmInnerPhone1.ParameterName = "@InnerPhone1";
                        prmInnerPhone1.DbType = DbType.String;
                        if (InnerPhone1 == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmInnerPhone1.Value = InnerPhone1;
                        }


                        lstRet = Select(con, "" , " where [InnerPhone1]=@InnerPhone1 ", prmInnerPhone1);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByInnerPhone1(System.String InnerPhone1)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByInnerPhone1(con, InnerPhone1);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByPhone2(ClassDataHandler con,System.String Phone2)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmPhone2 = con.createParameter();
                        prmPhone2.ParameterName = "@Phone2";
                        prmPhone2.DbType = DbType.String;
                        if (Phone2 == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmPhone2.Value = Phone2;
                        }


                        lstRet = Select(con, "" , " where [Phone2]=@Phone2 ", prmPhone2);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByPhone2(System.String Phone2)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByPhone2(con, Phone2);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByInnerPhone2(ClassDataHandler con,System.String InnerPhone2)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmInnerPhone2 = con.createParameter();
                        prmInnerPhone2.ParameterName = "@InnerPhone2";
                        prmInnerPhone2.DbType = DbType.String;
                        if (InnerPhone2 == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmInnerPhone2.Value = InnerPhone2;
                        }


                        lstRet = Select(con, "" , " where [InnerPhone2]=@InnerPhone2 ", prmInnerPhone2);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByInnerPhone2(System.String InnerPhone2)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByInnerPhone2(con, InnerPhone2);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByLanguage(ClassDataHandler con,System.Int64? Language)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmLanguage = con.createParameter();
                        prmLanguage.ParameterName = "@Language";
                        prmLanguage.DbType = DbType.Int64;
                        if (Language == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmLanguage.Value = Language;
                        }


                        lstRet = Select(con, "" , " where [Language]=@Language ", prmLanguage);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByLanguage(System.Int64? Language)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByLanguage(con, Language);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByStatusID(ClassDataHandler con,System.Int64 StatusID)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmStatusID = con.createParameter();
                        prmStatusID.ParameterName = "@StatusID";
                        prmStatusID.DbType = DbType.Int64;
                        if (StatusID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmStatusID.Value = StatusID;
                        }


                        lstRet = Select(con, "" , " where [StatusID]=@StatusID ", prmStatusID);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByStatusID(System.Int64 StatusID)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByStatusID(con, StatusID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByEmploymentStatus(ClassDataHandler con,System.Int64? EmploymentStatus)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmEmploymentStatus = con.createParameter();
                        prmEmploymentStatus.ParameterName = "@EmploymentStatus";
                        prmEmploymentStatus.DbType = DbType.Int64;
                        if (EmploymentStatus == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmEmploymentStatus.Value = EmploymentStatus;
                        }


                        lstRet = Select(con, "" , " where [EmploymentStatus]=@EmploymentStatus ", prmEmploymentStatus);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByEmploymentStatus(System.Int64? EmploymentStatus)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByEmploymentStatus(con, EmploymentStatus);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByEducationLevel(ClassDataHandler con,System.Int64 EducationLevel)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmEducationLevel = con.createParameter();
                        prmEducationLevel.ParameterName = "@EducationLevel";
                        prmEducationLevel.DbType = DbType.Int64;
                        if (EducationLevel == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmEducationLevel.Value = EducationLevel;
                        }


                        lstRet = Select(con, "" , " where [EducationLevel]=@EducationLevel ", prmEducationLevel);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByEducationLevel(System.Int64 EducationLevel)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByEducationLevel(con, EducationLevel);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByPositionEmail(ClassDataHandler con,System.String PositionEmail)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmPositionEmail = con.createParameter();
                        prmPositionEmail.ParameterName = "@PositionEmail";
                        prmPositionEmail.DbType = DbType.String;
                        if (PositionEmail == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmPositionEmail.Value = PositionEmail;
                        }


                        lstRet = Select(con, "" , " where [PositionEmail]=@PositionEmail ", prmPositionEmail);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByPositionEmail(System.String PositionEmail)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByPositionEmail(con, PositionEmail);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByOfficePhone(ClassDataHandler con,System.String OfficePhone)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmOfficePhone = con.createParameter();
                        prmOfficePhone.ParameterName = "@OfficePhone";
                        prmOfficePhone.DbType = DbType.String;
                        if (OfficePhone == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmOfficePhone.Value = OfficePhone;
                        }


                        lstRet = Select(con, "" , " where [OfficePhone]=@OfficePhone ", prmOfficePhone);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByOfficePhone(System.String OfficePhone)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByOfficePhone(con, OfficePhone);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Persons> getPersonsByOfficeInnerPhone(ClassDataHandler con,System.String OfficeInnerPhone)
                    {
                        List<Persons> lstRet = new List<Persons>();


                        DbParameter prmOfficeInnerPhone = con.createParameter();
                        prmOfficeInnerPhone.ParameterName = "@OfficeInnerPhone";
                        prmOfficeInnerPhone.DbType = DbType.String;
                        if (OfficeInnerPhone == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmOfficeInnerPhone.Value = OfficeInnerPhone;
                        }


                        lstRet = Select(con, "" , " where [OfficeInnerPhone]=@OfficeInnerPhone ", prmOfficeInnerPhone);



                        return lstRet;

                    }


                    public List<Persons> getPersonsByOfficeInnerPhone(System.String OfficeInnerPhone)
                    {
                        List<Persons> lstRet = new List<Persons>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getPersonsByOfficeInnerPhone(con, OfficeInnerPhone);

                        con.CloseConnection();

                        return lstRet;

                    }



                

            
public List<Persons> Search(ClassDataHandler con, Persons obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.GenID != -1)
                    {
                        DbParameter prmGenID = con.createParameter();
                        prmGenID.ParameterName = "@GenID";
                        prmGenID.DbType =DbType.Int64;
                        if (obj.GenID == null)
                        {
                            prmGenID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmGenID.Value = obj.GenID;
                        }
                        strWhere += " [GenID]=@GenID AND ";
                        lstParameters.Add(prmGenID);
                     }



                    

                    if (obj.Name_AR != "")
                    {
                        DbParameter prmName_AR = con.createParameter();
                        prmName_AR.ParameterName = "@Name_AR";
                        prmName_AR.DbType =DbType.String;
                        if (obj.Name_AR == null)
                        {
                            prmName_AR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmName_AR.Value = obj.Name_AR;
                        }
                        strWhere += " [Name_AR]=@Name_AR AND ";
                        lstParameters.Add(prmName_AR);
                     }



                    

                    if (obj.Name_EN != "")
                    {
                        DbParameter prmName_EN = con.createParameter();
                        prmName_EN.ParameterName = "@Name_EN";
                        prmName_EN.DbType =DbType.String;
                        if (obj.Name_EN == null)
                        {
                            prmName_EN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmName_EN.Value = obj.Name_EN;
                        }
                        strWhere += " [Name_EN]=@Name_EN AND ";
                        lstParameters.Add(prmName_EN);
                     }



                    

                    if (obj.MiddleName_AR != "")
                    {
                        DbParameter prmMiddleName_AR = con.createParameter();
                        prmMiddleName_AR.ParameterName = "@MiddleName_AR";
                        prmMiddleName_AR.DbType =DbType.String;
                        if (obj.MiddleName_AR == null)
                        {
                            prmMiddleName_AR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmMiddleName_AR.Value = obj.MiddleName_AR;
                        }
                        strWhere += " [MiddleName_AR]=@MiddleName_AR AND ";
                        lstParameters.Add(prmMiddleName_AR);
                     }



                    

                    if (obj.MiddleName_EN != "")
                    {
                        DbParameter prmMiddleName_EN = con.createParameter();
                        prmMiddleName_EN.ParameterName = "@MiddleName_EN";
                        prmMiddleName_EN.DbType =DbType.String;
                        if (obj.MiddleName_EN == null)
                        {
                            prmMiddleName_EN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmMiddleName_EN.Value = obj.MiddleName_EN;
                        }
                        strWhere += " [MiddleName_EN]=@MiddleName_EN AND ";
                        lstParameters.Add(prmMiddleName_EN);
                     }



                    

                    if (obj.FamilyName_AR != "")
                    {
                        DbParameter prmFamilyName_AR = con.createParameter();
                        prmFamilyName_AR.ParameterName = "@FamilyName_AR";
                        prmFamilyName_AR.DbType =DbType.String;
                        if (obj.FamilyName_AR == null)
                        {
                            prmFamilyName_AR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmFamilyName_AR.Value = obj.FamilyName_AR;
                        }
                        strWhere += " [FamilyName_AR]=@FamilyName_AR AND ";
                        lstParameters.Add(prmFamilyName_AR);
                     }



                    

                    if (obj.FamilyName_EN != "")
                    {
                        DbParameter prmFamilyName_EN = con.createParameter();
                        prmFamilyName_EN.ParameterName = "@FamilyName_EN";
                        prmFamilyName_EN.DbType =DbType.String;
                        if (obj.FamilyName_EN == null)
                        {
                            prmFamilyName_EN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmFamilyName_EN.Value = obj.FamilyName_EN;
                        }
                        strWhere += " [FamilyName_EN]=@FamilyName_EN AND ";
                        lstParameters.Add(prmFamilyName_EN);
                     }



                    

                    if (obj.Gender != false)
                    {
                        DbParameter prmGender = con.createParameter();
                        prmGender.ParameterName = "@Gender";
                        prmGender.DbType =DbType.Boolean;
                        if (obj.Gender == null)
                        {
                            prmGender.Value = DBNull.Value;
                        }
                        else
                        {
                            prmGender.Value = obj.Gender;
                        }
                        strWhere += " [Gender]=@Gender AND ";
                        lstParameters.Add(prmGender);
                     }



                    

                    if (obj.Badge != "")
                    {
                        DbParameter prmBadge = con.createParameter();
                        prmBadge.ParameterName = "@Badge";
                        prmBadge.DbType =DbType.String;
                        if (obj.Badge == null)
                        {
                            prmBadge.Value = DBNull.Value;
                        }
                        else
                        {
                            prmBadge.Value = obj.Badge;
                        }
                        strWhere += " [Badge]=@Badge AND ";
                        lstParameters.Add(prmBadge);
                     }



                    

                    if (obj.ID != "")
                    {
                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType =DbType.String;
                        if (obj.ID == null)
                        {
                            prmID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmID.Value = obj.ID;
                        }
                        strWhere += " [ID]=@ID AND ";
                        lstParameters.Add(prmID);
                     }



                    

                    if (obj.BirthDate != null)
                    {
                        DbParameter prmBirthDate = con.createParameter();
                        prmBirthDate.ParameterName = "@BirthDate";
                        prmBirthDate.DbType =DbType.DateTime;
                        if (obj.BirthDate == null)
                        {
                            prmBirthDate.Value = DBNull.Value;
                        }
                        else
                        {
                            prmBirthDate.Value = obj.BirthDate;
                        }
                        strWhere += " [BirthDate]=@BirthDate AND ";
                        lstParameters.Add(prmBirthDate);
                     }



                    

                    if (obj.RelationID != null)
                    {
                        DbParameter prmRelationID = con.createParameter();
                        prmRelationID.ParameterName = "@RelationID";
                        prmRelationID.DbType =DbType.Int64;
                        if (obj.RelationID == null)
                        {
                            prmRelationID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmRelationID.Value = obj.RelationID;
                        }
                        strWhere += " [RelationID]=@RelationID AND ";
                        lstParameters.Add(prmRelationID);
                     }



                    

                    if (obj.NationalityID != null)
                    {
                        DbParameter prmNationalityID = con.createParameter();
                        prmNationalityID.ParameterName = "@NationalityID";
                        prmNationalityID.DbType =DbType.Int64;
                        if (obj.NationalityID == null)
                        {
                            prmNationalityID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmNationalityID.Value = obj.NationalityID;
                        }
                        strWhere += " [NationalityID]=@NationalityID AND ";
                        lstParameters.Add(prmNationalityID);
                     }



                    

                    if (obj.OperationAreaID != null)
                    {
                        DbParameter prmOperationAreaID = con.createParameter();
                        prmOperationAreaID.ParameterName = "@OperationAreaID";
                        prmOperationAreaID.DbType =DbType.Int64;
                        if (obj.OperationAreaID == null)
                        {
                            prmOperationAreaID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmOperationAreaID.Value = obj.OperationAreaID;
                        }
                        strWhere += " [OperationAreaID]=@OperationAreaID AND ";
                        lstParameters.Add(prmOperationAreaID);
                     }



                    

                    if (obj.PersonTypeID != null)
                    {
                        DbParameter prmPersonTypeID = con.createParameter();
                        prmPersonTypeID.ParameterName = "@PersonTypeID";
                        prmPersonTypeID.DbType =DbType.Int64;
                        if (obj.PersonTypeID == null)
                        {
                            prmPersonTypeID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPersonTypeID.Value = obj.PersonTypeID;
                        }
                        strWhere += " [PersonTypeID]=@PersonTypeID AND ";
                        lstParameters.Add(prmPersonTypeID);
                     }



                    

                    if (obj.ChargeAccount != "")
                    {
                        DbParameter prmChargeAccount = con.createParameter();
                        prmChargeAccount.ParameterName = "@ChargeAccount";
                        prmChargeAccount.DbType =DbType.String;
                        if (obj.ChargeAccount == null)
                        {
                            prmChargeAccount.Value = DBNull.Value;
                        }
                        else
                        {
                            prmChargeAccount.Value = obj.ChargeAccount;
                        }
                        strWhere += " [ChargeAccount]=@ChargeAccount AND ";
                        lstParameters.Add(prmChargeAccount);
                     }



                    

                    if (obj.OrgChartID != null)
                    {
                        DbParameter prmOrgChartID = con.createParameter();
                        prmOrgChartID.ParameterName = "@OrgChartID";
                        prmOrgChartID.DbType =DbType.Int64;
                        if (obj.OrgChartID == null)
                        {
                            prmOrgChartID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmOrgChartID.Value = obj.OrgChartID;
                        }
                        strWhere += " [OrgChartID]=@OrgChartID AND ";
                        lstParameters.Add(prmOrgChartID);
                     }



                    

                    if (obj.Email != "")
                    {
                        DbParameter prmEmail = con.createParameter();
                        prmEmail.ParameterName = "@Email";
                        prmEmail.DbType =DbType.String;
                        if (obj.Email == null)
                        {
                            prmEmail.Value = DBNull.Value;
                        }
                        else
                        {
                            prmEmail.Value = obj.Email;
                        }
                        strWhere += " [Email]=@Email AND ";
                        lstParameters.Add(prmEmail);
                     }



                    

                    if (obj.Password != "")
                    {
                        DbParameter prmPassword = con.createParameter();
                        prmPassword.ParameterName = "@Password";
                        prmPassword.DbType =DbType.String;
                        if (obj.Password == null)
                        {
                            prmPassword.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPassword.Value = obj.Password;
                        }
                        strWhere += " [Password]=@Password AND ";
                        lstParameters.Add(prmPassword);
                     }



                    

                    if (obj.UserTypeID != -1)
                    {
                        DbParameter prmUserTypeID = con.createParameter();
                        prmUserTypeID.ParameterName = "@UserTypeID";
                        prmUserTypeID.DbType =DbType.Int64;
                        if (obj.UserTypeID == null)
                        {
                            prmUserTypeID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmUserTypeID.Value = obj.UserTypeID;
                        }
                        strWhere += " [UserTypeID]=@UserTypeID AND ";
                        lstParameters.Add(prmUserTypeID);
                     }



                    

                    if (obj.Mobile1 != "")
                    {
                        DbParameter prmMobile1 = con.createParameter();
                        prmMobile1.ParameterName = "@Mobile1";
                        prmMobile1.DbType =DbType.String;
                        if (obj.Mobile1 == null)
                        {
                            prmMobile1.Value = DBNull.Value;
                        }
                        else
                        {
                            prmMobile1.Value = obj.Mobile1;
                        }
                        strWhere += " [Mobile1]=@Mobile1 AND ";
                        lstParameters.Add(prmMobile1);
                     }



                    

                    if (obj.Mobile2 != "")
                    {
                        DbParameter prmMobile2 = con.createParameter();
                        prmMobile2.ParameterName = "@Mobile2";
                        prmMobile2.DbType =DbType.String;
                        if (obj.Mobile2 == null)
                        {
                            prmMobile2.Value = DBNull.Value;
                        }
                        else
                        {
                            prmMobile2.Value = obj.Mobile2;
                        }
                        strWhere += " [Mobile2]=@Mobile2 AND ";
                        lstParameters.Add(prmMobile2);
                     }



                    

                    if (obj.Phone1 != "")
                    {
                        DbParameter prmPhone1 = con.createParameter();
                        prmPhone1.ParameterName = "@Phone1";
                        prmPhone1.DbType =DbType.String;
                        if (obj.Phone1 == null)
                        {
                            prmPhone1.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPhone1.Value = obj.Phone1;
                        }
                        strWhere += " [Phone1]=@Phone1 AND ";
                        lstParameters.Add(prmPhone1);
                     }



                    

                    if (obj.InnerPhone1 != "")
                    {
                        DbParameter prmInnerPhone1 = con.createParameter();
                        prmInnerPhone1.ParameterName = "@InnerPhone1";
                        prmInnerPhone1.DbType =DbType.String;
                        if (obj.InnerPhone1 == null)
                        {
                            prmInnerPhone1.Value = DBNull.Value;
                        }
                        else
                        {
                            prmInnerPhone1.Value = obj.InnerPhone1;
                        }
                        strWhere += " [InnerPhone1]=@InnerPhone1 AND ";
                        lstParameters.Add(prmInnerPhone1);
                     }



                    

                    if (obj.Phone2 != "")
                    {
                        DbParameter prmPhone2 = con.createParameter();
                        prmPhone2.ParameterName = "@Phone2";
                        prmPhone2.DbType =DbType.String;
                        if (obj.Phone2 == null)
                        {
                            prmPhone2.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPhone2.Value = obj.Phone2;
                        }
                        strWhere += " [Phone2]=@Phone2 AND ";
                        lstParameters.Add(prmPhone2);
                     }



                    

                    if (obj.InnerPhone2 != "")
                    {
                        DbParameter prmInnerPhone2 = con.createParameter();
                        prmInnerPhone2.ParameterName = "@InnerPhone2";
                        prmInnerPhone2.DbType =DbType.String;
                        if (obj.InnerPhone2 == null)
                        {
                            prmInnerPhone2.Value = DBNull.Value;
                        }
                        else
                        {
                            prmInnerPhone2.Value = obj.InnerPhone2;
                        }
                        strWhere += " [InnerPhone2]=@InnerPhone2 AND ";
                        lstParameters.Add(prmInnerPhone2);
                     }



                    

                    if (obj.Language != null)
                    {
                        DbParameter prmLanguage = con.createParameter();
                        prmLanguage.ParameterName = "@Language";
                        prmLanguage.DbType =DbType.Int64;
                        if (obj.Language == null)
                        {
                            prmLanguage.Value = DBNull.Value;
                        }
                        else
                        {
                            prmLanguage.Value = obj.Language;
                        }
                        strWhere += " [Language]=@Language AND ";
                        lstParameters.Add(prmLanguage);
                     }



                    

                    if (obj.StatusID != -1)
                    {
                        DbParameter prmStatusID = con.createParameter();
                        prmStatusID.ParameterName = "@StatusID";
                        prmStatusID.DbType =DbType.Int64;
                        if (obj.StatusID == null)
                        {
                            prmStatusID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmStatusID.Value = obj.StatusID;
                        }
                        strWhere += " [StatusID]=@StatusID AND ";
                        lstParameters.Add(prmStatusID);
                     }



                    

                    if (obj.EmploymentStatus != null)
                    {
                        DbParameter prmEmploymentStatus = con.createParameter();
                        prmEmploymentStatus.ParameterName = "@EmploymentStatus";
                        prmEmploymentStatus.DbType =DbType.Int64;
                        if (obj.EmploymentStatus == null)
                        {
                            prmEmploymentStatus.Value = DBNull.Value;
                        }
                        else
                        {
                            prmEmploymentStatus.Value = obj.EmploymentStatus;
                        }
                        strWhere += " [EmploymentStatus]=@EmploymentStatus AND ";
                        lstParameters.Add(prmEmploymentStatus);
                     }



                    

                    if (obj.EducationLevel != -1)
                    {
                        DbParameter prmEducationLevel = con.createParameter();
                        prmEducationLevel.ParameterName = "@EducationLevel";
                        prmEducationLevel.DbType =DbType.Int64;
                        if (obj.EducationLevel == null)
                        {
                            prmEducationLevel.Value = DBNull.Value;
                        }
                        else
                        {
                            prmEducationLevel.Value = obj.EducationLevel;
                        }
                        strWhere += " [EducationLevel]=@EducationLevel AND ";
                        lstParameters.Add(prmEducationLevel);
                     }



                    

                    if (obj.PositionEmail != "")
                    {
                        DbParameter prmPositionEmail = con.createParameter();
                        prmPositionEmail.ParameterName = "@PositionEmail";
                        prmPositionEmail.DbType =DbType.String;
                        if (obj.PositionEmail == null)
                        {
                            prmPositionEmail.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPositionEmail.Value = obj.PositionEmail;
                        }
                        strWhere += " [PositionEmail]=@PositionEmail AND ";
                        lstParameters.Add(prmPositionEmail);
                     }



                    

                    if (obj.OfficePhone != "")
                    {
                        DbParameter prmOfficePhone = con.createParameter();
                        prmOfficePhone.ParameterName = "@OfficePhone";
                        prmOfficePhone.DbType =DbType.String;
                        if (obj.OfficePhone == null)
                        {
                            prmOfficePhone.Value = DBNull.Value;
                        }
                        else
                        {
                            prmOfficePhone.Value = obj.OfficePhone;
                        }
                        strWhere += " [OfficePhone]=@OfficePhone AND ";
                        lstParameters.Add(prmOfficePhone);
                     }



                    

                    if (obj.OfficeInnerPhone != "")
                    {
                        DbParameter prmOfficeInnerPhone = con.createParameter();
                        prmOfficeInnerPhone.ParameterName = "@OfficeInnerPhone";
                        prmOfficeInnerPhone.DbType =DbType.String;
                        if (obj.OfficeInnerPhone == null)
                        {
                            prmOfficeInnerPhone.Value = DBNull.Value;
                        }
                        else
                        {
                            prmOfficeInnerPhone.Value = obj.OfficeInnerPhone;
                        }
                        strWhere += " [OfficeInnerPhone]=@OfficeInnerPhone AND ";
                        lstParameters.Add(prmOfficeInnerPhone);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("AND"));

                    

            

            List<Persons> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<Persons> Search(Persons obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<Persons> lstRet = Search(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                

            
public List<Persons> SearchOrLike(ClassDataHandler con, Persons obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.GenID != -1)
                    {
                        DbParameter prmGenID = con.createParameter();
                        prmGenID.ParameterName = "@GenID";
                        prmGenID.DbType =DbType.Int64;
                        if (obj.GenID == null)
                        {
                            prmGenID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmGenID.Value = obj.GenID;
                        }
                        strWhere += " [GenID]=@GenID OR ";
                        lstParameters.Add(prmGenID);
                     }



                    

                    if (obj.Name_AR != "")
                    {
                        DbParameter prmName_AR = con.createParameter();
                        prmName_AR.ParameterName = "@Name_AR";
                        prmName_AR.DbType =DbType.String;
                        if (obj.Name_AR == null)
                        {
                            prmName_AR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmName_AR.Value = obj.Name_AR;
                        }
                        strWhere += " [Name_AR] LIKE @Name_AR OR ";
                        lstParameters.Add(prmName_AR);
                     }



                    

                    if (obj.Name_EN != "")
                    {
                        DbParameter prmName_EN = con.createParameter();
                        prmName_EN.ParameterName = "@Name_EN";
                        prmName_EN.DbType =DbType.String;
                        if (obj.Name_EN == null)
                        {
                            prmName_EN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmName_EN.Value = obj.Name_EN;
                        }
                        strWhere += " [Name_EN] LIKE @Name_EN OR ";
                        lstParameters.Add(prmName_EN);
                     }



                    

                    if (obj.MiddleName_AR != "")
                    {
                        DbParameter prmMiddleName_AR = con.createParameter();
                        prmMiddleName_AR.ParameterName = "@MiddleName_AR";
                        prmMiddleName_AR.DbType =DbType.String;
                        if (obj.MiddleName_AR == null)
                        {
                            prmMiddleName_AR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmMiddleName_AR.Value = obj.MiddleName_AR;
                        }
                        strWhere += " [MiddleName_AR] LIKE @MiddleName_AR OR ";
                        lstParameters.Add(prmMiddleName_AR);
                     }



                    

                    if (obj.MiddleName_EN != "")
                    {
                        DbParameter prmMiddleName_EN = con.createParameter();
                        prmMiddleName_EN.ParameterName = "@MiddleName_EN";
                        prmMiddleName_EN.DbType =DbType.String;
                        if (obj.MiddleName_EN == null)
                        {
                            prmMiddleName_EN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmMiddleName_EN.Value = obj.MiddleName_EN;
                        }
                        strWhere += " [MiddleName_EN] LIKE @MiddleName_EN OR ";
                        lstParameters.Add(prmMiddleName_EN);
                     }



                    

                    if (obj.FamilyName_AR != "")
                    {
                        DbParameter prmFamilyName_AR = con.createParameter();
                        prmFamilyName_AR.ParameterName = "@FamilyName_AR";
                        prmFamilyName_AR.DbType =DbType.String;
                        if (obj.FamilyName_AR == null)
                        {
                            prmFamilyName_AR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmFamilyName_AR.Value = obj.FamilyName_AR;
                        }
                        strWhere += " [FamilyName_AR] LIKE @FamilyName_AR OR ";
                        lstParameters.Add(prmFamilyName_AR);
                     }



                    

                    if (obj.FamilyName_EN != "")
                    {
                        DbParameter prmFamilyName_EN = con.createParameter();
                        prmFamilyName_EN.ParameterName = "@FamilyName_EN";
                        prmFamilyName_EN.DbType =DbType.String;
                        if (obj.FamilyName_EN == null)
                        {
                            prmFamilyName_EN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmFamilyName_EN.Value = obj.FamilyName_EN;
                        }
                        strWhere += " [FamilyName_EN] LIKE @FamilyName_EN OR ";
                        lstParameters.Add(prmFamilyName_EN);
                     }



                    

                    if (obj.Gender != false)
                    {
                        DbParameter prmGender = con.createParameter();
                        prmGender.ParameterName = "@Gender";
                        prmGender.DbType =DbType.Boolean;
                        if (obj.Gender == null)
                        {
                            prmGender.Value = DBNull.Value;
                        }
                        else
                        {
                            prmGender.Value = obj.Gender;
                        }
                        strWhere += " [Gender]=@Gender OR ";
                        lstParameters.Add(prmGender);
                     }



                    

                    if (obj.Badge != "")
                    {
                        DbParameter prmBadge = con.createParameter();
                        prmBadge.ParameterName = "@Badge";
                        prmBadge.DbType =DbType.String;
                        if (obj.Badge == null)
                        {
                            prmBadge.Value = DBNull.Value;
                        }
                        else
                        {
                            prmBadge.Value = obj.Badge;
                        }
                        strWhere += " [Badge] LIKE @Badge OR ";
                        lstParameters.Add(prmBadge);
                     }



                    

                    if (obj.ID != "")
                    {
                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType =DbType.String;
                        if (obj.ID == null)
                        {
                            prmID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmID.Value = obj.ID;
                        }
                        strWhere += " [ID] LIKE @ID OR ";
                        lstParameters.Add(prmID);
                     }



                    

                    if (obj.BirthDate != null)
                    {
                        DbParameter prmBirthDate = con.createParameter();
                        prmBirthDate.ParameterName = "@BirthDate";
                        prmBirthDate.DbType =DbType.DateTime;
                        if (obj.BirthDate == null)
                        {
                            prmBirthDate.Value = DBNull.Value;
                        }
                        else
                        {
                            prmBirthDate.Value = obj.BirthDate;
                        }
                        strWhere += " [BirthDate]=@BirthDate OR ";
                        lstParameters.Add(prmBirthDate);
                     }



                    

                    if (obj.RelationID != null)
                    {
                        DbParameter prmRelationID = con.createParameter();
                        prmRelationID.ParameterName = "@RelationID";
                        prmRelationID.DbType =DbType.Int64;
                        if (obj.RelationID == null)
                        {
                            prmRelationID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmRelationID.Value = obj.RelationID;
                        }
                        strWhere += " [RelationID]=@RelationID OR ";
                        lstParameters.Add(prmRelationID);
                     }



                    

                    if (obj.NationalityID != null)
                    {
                        DbParameter prmNationalityID = con.createParameter();
                        prmNationalityID.ParameterName = "@NationalityID";
                        prmNationalityID.DbType =DbType.Int64;
                        if (obj.NationalityID == null)
                        {
                            prmNationalityID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmNationalityID.Value = obj.NationalityID;
                        }
                        strWhere += " [NationalityID]=@NationalityID OR ";
                        lstParameters.Add(prmNationalityID);
                     }



                    

                    if (obj.OperationAreaID != null)
                    {
                        DbParameter prmOperationAreaID = con.createParameter();
                        prmOperationAreaID.ParameterName = "@OperationAreaID";
                        prmOperationAreaID.DbType =DbType.Int64;
                        if (obj.OperationAreaID == null)
                        {
                            prmOperationAreaID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmOperationAreaID.Value = obj.OperationAreaID;
                        }
                        strWhere += " [OperationAreaID]=@OperationAreaID OR ";
                        lstParameters.Add(prmOperationAreaID);
                     }



                    

                    if (obj.PersonTypeID != null)
                    {
                        DbParameter prmPersonTypeID = con.createParameter();
                        prmPersonTypeID.ParameterName = "@PersonTypeID";
                        prmPersonTypeID.DbType =DbType.Int64;
                        if (obj.PersonTypeID == null)
                        {
                            prmPersonTypeID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPersonTypeID.Value = obj.PersonTypeID;
                        }
                        strWhere += " [PersonTypeID]=@PersonTypeID OR ";
                        lstParameters.Add(prmPersonTypeID);
                     }



                    

                    if (obj.ChargeAccount != "")
                    {
                        DbParameter prmChargeAccount = con.createParameter();
                        prmChargeAccount.ParameterName = "@ChargeAccount";
                        prmChargeAccount.DbType =DbType.String;
                        if (obj.ChargeAccount == null)
                        {
                            prmChargeAccount.Value = DBNull.Value;
                        }
                        else
                        {
                            prmChargeAccount.Value = obj.ChargeAccount;
                        }
                        strWhere += " [ChargeAccount] LIKE @ChargeAccount OR ";
                        lstParameters.Add(prmChargeAccount);
                     }



                    

                    if (obj.OrgChartID != null)
                    {
                        DbParameter prmOrgChartID = con.createParameter();
                        prmOrgChartID.ParameterName = "@OrgChartID";
                        prmOrgChartID.DbType =DbType.Int64;
                        if (obj.OrgChartID == null)
                        {
                            prmOrgChartID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmOrgChartID.Value = obj.OrgChartID;
                        }
                        strWhere += " [OrgChartID]=@OrgChartID OR ";
                        lstParameters.Add(prmOrgChartID);
                     }



                    

                    if (obj.Email != "")
                    {
                        DbParameter prmEmail = con.createParameter();
                        prmEmail.ParameterName = "@Email";
                        prmEmail.DbType =DbType.String;
                        if (obj.Email == null)
                        {
                            prmEmail.Value = DBNull.Value;
                        }
                        else
                        {
                            prmEmail.Value = obj.Email;
                        }
                        strWhere += " [Email] LIKE @Email OR ";
                        lstParameters.Add(prmEmail);
                     }



                    

                    if (obj.Password != "")
                    {
                        DbParameter prmPassword = con.createParameter();
                        prmPassword.ParameterName = "@Password";
                        prmPassword.DbType =DbType.String;
                        if (obj.Password == null)
                        {
                            prmPassword.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPassword.Value = obj.Password;
                        }
                        strWhere += " [Password] LIKE @Password OR ";
                        lstParameters.Add(prmPassword);
                     }



                    

                    if (obj.UserTypeID != -1)
                    {
                        DbParameter prmUserTypeID = con.createParameter();
                        prmUserTypeID.ParameterName = "@UserTypeID";
                        prmUserTypeID.DbType =DbType.Int64;
                        if (obj.UserTypeID == null)
                        {
                            prmUserTypeID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmUserTypeID.Value = obj.UserTypeID;
                        }
                        strWhere += " [UserTypeID]=@UserTypeID OR ";
                        lstParameters.Add(prmUserTypeID);
                     }



                    

                    if (obj.Mobile1 != "")
                    {
                        DbParameter prmMobile1 = con.createParameter();
                        prmMobile1.ParameterName = "@Mobile1";
                        prmMobile1.DbType =DbType.String;
                        if (obj.Mobile1 == null)
                        {
                            prmMobile1.Value = DBNull.Value;
                        }
                        else
                        {
                            prmMobile1.Value = obj.Mobile1;
                        }
                        strWhere += " [Mobile1] LIKE @Mobile1 OR ";
                        lstParameters.Add(prmMobile1);
                     }



                    

                    if (obj.Mobile2 != "")
                    {
                        DbParameter prmMobile2 = con.createParameter();
                        prmMobile2.ParameterName = "@Mobile2";
                        prmMobile2.DbType =DbType.String;
                        if (obj.Mobile2 == null)
                        {
                            prmMobile2.Value = DBNull.Value;
                        }
                        else
                        {
                            prmMobile2.Value = obj.Mobile2;
                        }
                        strWhere += " [Mobile2] LIKE @Mobile2 OR ";
                        lstParameters.Add(prmMobile2);
                     }



                    

                    if (obj.Phone1 != "")
                    {
                        DbParameter prmPhone1 = con.createParameter();
                        prmPhone1.ParameterName = "@Phone1";
                        prmPhone1.DbType =DbType.String;
                        if (obj.Phone1 == null)
                        {
                            prmPhone1.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPhone1.Value = obj.Phone1;
                        }
                        strWhere += " [Phone1] LIKE @Phone1 OR ";
                        lstParameters.Add(prmPhone1);
                     }



                    

                    if (obj.InnerPhone1 != "")
                    {
                        DbParameter prmInnerPhone1 = con.createParameter();
                        prmInnerPhone1.ParameterName = "@InnerPhone1";
                        prmInnerPhone1.DbType =DbType.String;
                        if (obj.InnerPhone1 == null)
                        {
                            prmInnerPhone1.Value = DBNull.Value;
                        }
                        else
                        {
                            prmInnerPhone1.Value = obj.InnerPhone1;
                        }
                        strWhere += " [InnerPhone1] LIKE @InnerPhone1 OR ";
                        lstParameters.Add(prmInnerPhone1);
                     }



                    

                    if (obj.Phone2 != "")
                    {
                        DbParameter prmPhone2 = con.createParameter();
                        prmPhone2.ParameterName = "@Phone2";
                        prmPhone2.DbType =DbType.String;
                        if (obj.Phone2 == null)
                        {
                            prmPhone2.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPhone2.Value = obj.Phone2;
                        }
                        strWhere += " [Phone2] LIKE @Phone2 OR ";
                        lstParameters.Add(prmPhone2);
                     }



                    

                    if (obj.InnerPhone2 != "")
                    {
                        DbParameter prmInnerPhone2 = con.createParameter();
                        prmInnerPhone2.ParameterName = "@InnerPhone2";
                        prmInnerPhone2.DbType =DbType.String;
                        if (obj.InnerPhone2 == null)
                        {
                            prmInnerPhone2.Value = DBNull.Value;
                        }
                        else
                        {
                            prmInnerPhone2.Value = obj.InnerPhone2;
                        }
                        strWhere += " [InnerPhone2] LIKE @InnerPhone2 OR ";
                        lstParameters.Add(prmInnerPhone2);
                     }



                    

                    if (obj.Language != null)
                    {
                        DbParameter prmLanguage = con.createParameter();
                        prmLanguage.ParameterName = "@Language";
                        prmLanguage.DbType =DbType.Int64;
                        if (obj.Language == null)
                        {
                            prmLanguage.Value = DBNull.Value;
                        }
                        else
                        {
                            prmLanguage.Value = obj.Language;
                        }
                        strWhere += " [Language]=@Language OR ";
                        lstParameters.Add(prmLanguage);
                     }



                    

                    if (obj.StatusID != -1)
                    {
                        DbParameter prmStatusID = con.createParameter();
                        prmStatusID.ParameterName = "@StatusID";
                        prmStatusID.DbType =DbType.Int64;
                        if (obj.StatusID == null)
                        {
                            prmStatusID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmStatusID.Value = obj.StatusID;
                        }
                        strWhere += " [StatusID]=@StatusID OR ";
                        lstParameters.Add(prmStatusID);
                     }



                    

                    if (obj.EmploymentStatus != null)
                    {
                        DbParameter prmEmploymentStatus = con.createParameter();
                        prmEmploymentStatus.ParameterName = "@EmploymentStatus";
                        prmEmploymentStatus.DbType =DbType.Int64;
                        if (obj.EmploymentStatus == null)
                        {
                            prmEmploymentStatus.Value = DBNull.Value;
                        }
                        else
                        {
                            prmEmploymentStatus.Value = obj.EmploymentStatus;
                        }
                        strWhere += " [EmploymentStatus]=@EmploymentStatus OR ";
                        lstParameters.Add(prmEmploymentStatus);
                     }



                    

                    if (obj.EducationLevel != -1)
                    {
                        DbParameter prmEducationLevel = con.createParameter();
                        prmEducationLevel.ParameterName = "@EducationLevel";
                        prmEducationLevel.DbType =DbType.Int64;
                        if (obj.EducationLevel == null)
                        {
                            prmEducationLevel.Value = DBNull.Value;
                        }
                        else
                        {
                            prmEducationLevel.Value = obj.EducationLevel;
                        }
                        strWhere += " [EducationLevel]=@EducationLevel OR ";
                        lstParameters.Add(prmEducationLevel);
                     }



                    

                    if (obj.PositionEmail != "")
                    {
                        DbParameter prmPositionEmail = con.createParameter();
                        prmPositionEmail.ParameterName = "@PositionEmail";
                        prmPositionEmail.DbType =DbType.String;
                        if (obj.PositionEmail == null)
                        {
                            prmPositionEmail.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPositionEmail.Value = obj.PositionEmail;
                        }
                        strWhere += " [PositionEmail] LIKE @PositionEmail OR ";
                        lstParameters.Add(prmPositionEmail);
                     }



                    

                    if (obj.OfficePhone != "")
                    {
                        DbParameter prmOfficePhone = con.createParameter();
                        prmOfficePhone.ParameterName = "@OfficePhone";
                        prmOfficePhone.DbType =DbType.String;
                        if (obj.OfficePhone == null)
                        {
                            prmOfficePhone.Value = DBNull.Value;
                        }
                        else
                        {
                            prmOfficePhone.Value = obj.OfficePhone;
                        }
                        strWhere += " [OfficePhone] LIKE @OfficePhone OR ";
                        lstParameters.Add(prmOfficePhone);
                     }



                    

                    if (obj.OfficeInnerPhone != "")
                    {
                        DbParameter prmOfficeInnerPhone = con.createParameter();
                        prmOfficeInnerPhone.ParameterName = "@OfficeInnerPhone";
                        prmOfficeInnerPhone.DbType =DbType.String;
                        if (obj.OfficeInnerPhone == null)
                        {
                            prmOfficeInnerPhone.Value = DBNull.Value;
                        }
                        else
                        {
                            prmOfficeInnerPhone.Value = obj.OfficeInnerPhone;
                        }
                        strWhere += " [OfficeInnerPhone] LIKE @OfficeInnerPhone OR ";
                        lstParameters.Add(prmOfficeInnerPhone);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("OR"));

                    

            

            List<Persons> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<Persons> SearchOrLike(Persons obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<Persons> lstRet = SearchOrLike(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                
        


       
        



    }
}











            